home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4567 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
  2. From: Dan Pop <danpop@mail.cern.ch>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: C type question
  5. Date: Mon, 5 Feb 1996 21:38:13 +0100
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <9602052038.AA06872@dxmint.cern.ch>
  8. References: <Pine.SUN.3.91.960202131027.20090A-100000@sun19.cs.cuhk.hk> <31165E58.104B@imsisoft.com>
  9. X-NNTP-Posting-Host: hpl3sn03.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11. X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
  12.  
  13. Victor Bazarov <vbazarov@imsisoft.com> writes:
  14.  
  15. >The problem is that some compilers expect "%le" for double values.
  16. >Their printf accepts %e, %f, or %g as formats for float values, not
  17. >double. So try %le.
  18.  
  19. Please read the FAQ before posting such nonsense.
  20.  
  21. 1. printf _cannot_ display float values at all.  Guess why.
  22.  
  23. 2. %e, %f and %g are all used for double values.
  24.  
  25. 3. %le in a printf format is meaningless and it invokes undefined behaviour.
  26.    Most vendors simply ignore the 'l' and treat %le as %e, but this is not
  27.    a valid reason for recommending its usage.
  28.  
  29. Here's the relevant paragraph from the C standard:
  30.  
  31.  * An optional h specifying that a following d , i , o , u , x , or X
  32.    conversion specifier applies to a short int or unsigned short int
  33.    argument (the argument will have been promoted according to the
  34.    integral promotions, and its value shall be converted to short int or
  35.    unsigned short int before printing); an optional h specifying that a
  36.    following n conversion specifier applies to a pointer to a short int
  37.    argument; an optional l (ell) specifying that a following d , i , o ,
  38.    u , x , or X conversion specifier applies to a long int or unsigned
  39.    long int argument; an optional l specifying that a following n
  40.    conversion specifier applies to a pointer to a long int argument; or
  41.    an optional L specifying that a following e , E , f , g , or G
  42.    conversion specifier applies to a long double argument.  If an h , l ,
  43.                                                             ^^^^^^^^^^^^^
  44.    or L appears with any other conversion specifier, the behavior is
  45.    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  46.    undefined.
  47.    ^^^^^^^^^^
  48. Dan
  49. -- 
  50. Dan Pop
  51. CERN, CN Division
  52. Email: danpop@mail.cern.ch 
  53. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  54.